/** layuiAdmin.std-v1.1.0 LPPL License By http://www.layui.com/admin/ */
;layui.define(["form", "upload"], function(t) {
    var i = layui.$
        , e = layui.layer
        , a = (layui.laytpl,
        layui.setter,
        layui.view,
        layui.admin)
        , n = layui.form
        , s = layui.upload;
    i("body");
    n.verify({
        nickname: function(t, i) {
            return new RegExp("^[a-zA-Z0-9_一-龥\\s·]+$").test(t) ? /(^\_)|(\__)|(\_+$)/.test(t) ? "用户名首尾不能出现下划线'_'" : /^\d+\d+\d$/.test(t) ? "用户名不能全为数字" : void 0 : "用户名不能有特殊字符"
        },
        pass: [/^[\S]{6,12}$/, "密码必须6到12位，且不能出现空格"],
        repass: function(t) {
            if (t !== i("#userPwd").val())
                return "两次密码输入不一致"
        }
    }),
        n.on("submit(set_website)", function(t) {
            return e.msg(JSON.stringify(t.field)),
                !1
        }),
        n.on("submit(set_system_email)", function(t) {
            return e.msg(JSON.stringify(t.field)),
                !1
        })
    var r = i("#LAY_avatarSrc");

        /*a.events.avartatPreview = function(t) {
            var i = r.val();
            e.photos({
                photos: {
                    title: "查看头像",
                    data: [{
                        src: i
                    }]
                },
                shade: .01,
                closeBtn: 1,
                anim: 5
            })
        }
        ,*/
        n.on("submit(setmypass)", function(t) {
            $.axseJson(hostUrl + "/user/updatePassword",
                JSON.stringify(t.field),
                function (res) {
                    if (res.status == 0) {
                        Layer.showSucMsg();
                        location.reload();
                    } else {
                        Layer.showFailMsg(res.msg, 0);
                    }
                },
                function () {
                    Layer.showFailMsg("系统网络开小差了，请稍后重试");
                })
            return false;
        }),
        t("set", {})

        // 取消按钮
        $("#cancel").on("click",function () {
            closeWindow();
        })

        // 关闭当前弹出窗口
        function closeWindow() {
            //先得到当前iframe层的索引
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index); //再执行关闭
        }
});
